/*
 * Attempt to solve the dividing sequence problem.
 */

#include "stdafx.h"
using namespace std;

int find_multiple(int number, int* arr, int startidx, int endidx, int* cnt)  {
	int max = 0;
	for(int i = startidx; i < endidx; i++)  {
		if(arr[i] % number == 0)
			if(cnt[i] > max)
				max = cnt[i];
	}
	return max;
}

void dividing_sequence_main()  {
	int n; // length of the input sequence;
	cin >> n;

	int* seq = new int[n];
	int* cnt = new int[n];
	for(int i = 0; i < n; i++) { 
		cin >> seq[i];
	}

	if(n == 1) {
		cout << 1;
	}
	else {
		int max = -1;

		// init last position
		cnt[n-1] = 1;
		// init pointers
		int pos = n - 2;
		for(; pos >= 0; pos--)  {
			cnt[pos] = 1 + find_multiple(seq[pos], seq, pos+1, n, cnt);
			if(cnt[pos] > max) max = cnt[pos];
		}
		cout << max;
	}

	delete [] seq;
	delete [] cnt;
}